const express = require("express");
const path = require("path");

const app = express();

// res.sendFile(filePath)

// GET http://localhost:3000
app.get("/", (req, res, next) => {
  res.sendFile(path.resolve(__dirname, "./public/index.html"));
});

// GET http://localhost:3000/about.html
app.get("/about.html", (req, res, next) => {
  res.sendFile(path.resolve(__dirname, "./public/about.html"));
});

// GET http://localhost:3000/base.css
app.get("/base.css", (req, res, next) => {
  res.sendFile(path.resolve(__dirname, "./public/base.css"));
});

// GET http://localhost:3000/index.js
app.get("/index.js", (req, res, next) => {
  res.sendFile(path.resolve(__dirname, "./public/index.js"));
});

app.listen(3000, () => {
  console.log("服务启动成功 http://localhost:3000");
});
